Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for imagetext models #22

Merged
merged 4 commits into from
Feb 26, 2024
Merged

Conversation

jzaldi
Copy link
Contributor

@jzaldi jzaldi commented Feb 21, 2024

Added support fort imagetext models

  • VertexAIImageCaptioning LLM based implementation of image captioning
  • VertexAIImageCaptioningChat Chat based implementation of image captioning
  • VertexAIVisualQnAChat Chat based implementation of image question and answering

There has to be at least other message with the first question.
"""

if len(messages) < 2:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should expect two messages, I'd rather suggest we should expect one with multiple content parts:

image_message = {
        "type": "image_url",
        "image_url": {"url": gcs_url},
}
text_message = {
        "type": "text",
        "text": "What is shown in this image?",
    }
message = HumanMessage(content=[text_message, image_message])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in order for it to work with the chat interface, each turn creates one message right? Maybe I can do so that the first is multimodal?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let's make it multimodal and it should expect only one message, so invocation would look smth like this:

response = model.invoke(
        input=[
            HumanMessage(content=[text_message, image_message])
        ]
    )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

@lkuligin lkuligin merged commit 8a00492 into langchain-ai:main Feb 26, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants